package com.ruoyi.web.controller.jimureport;

import com.ruoyi.common.jmreport.JMResult;
import com.ruoyi.system.domain.SysStudent;
import com.ruoyi.system.service.ISysStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/jmreport/api")
public class JimuController {

    @Resource
    private ISysStudentService iSysStudentService;

    @GetMapping("/student")
    public JMResult student(SysStudent sysStudent){
        List<SysStudent> list = iSysStudentService.list();
        return JMResult.result(list);
    }

    @GetMapping("/daping")
    public JMResult daping(){
        List<Map<String,Object>> list = new ArrayList<>();

        Map<String,Object> map1 = new HashMap<>();
        Map<String,Object> map2 = new HashMap<>();
        Map<String,Object> map3 = new HashMap<>();
        Map<String,Object> map4 = new HashMap<>();
        Map<String,Object> map5 = new HashMap<>();
        Map<String,Object> map6 = new HashMap<>();
        map1.put("name","淘宝");
        map1.put("value",(int)(Math.random()*100) + 1);
        map2.put("name","京东");
        map2.put("value",(int)(Math.random()*100) + 1);
        map3.put("name","拼多多");
        map3.put("value",(int)(Math.random()*100) + 1);
        map4.put("name","美团");
        map4.put("value",(int)(Math.random()*100) + 1);
        map5.put("name","抖音");
        map5.put("value",(int)(Math.random()*100) + 1);
        map6.put("name","苏宁");
        map6.put("value",(int)(Math.random()*100) + 1);
        list.add(map1);
        list.add(map2);
        list.add(map3);
        list.add(map4);
        list.add(map5);
        list.add(map6);
        return JMResult.result(list);
    }

    @GetMapping("/daping2")
    public JMResult daping2(){
        List<Map<String,Object>> list = new ArrayList<>();
        Map<String,Object> map1 = new HashMap<>();
        map1.put("name","速度");
        map1.put("value",(int)(Math.random()*100) + 1);
        list.add(map1);
        return JMResult.result(list);
    }

    @GetMapping("/daping3")
    public JMResult daping3(){
        List<Map<String,Object>> list = new ArrayList<>();
        Map<String,Object> map1 = new HashMap<>();
        Map<String,Object> map2 = new HashMap<>();
        Map<String,Object> map3 = new HashMap<>();
        Map<String,Object> map4 = new HashMap<>();
        Map<String,Object> map5 = new HashMap<>();
        Map<String,Object> map6 = new HashMap<>();
        map1.put("name","java语言");
        map1.put("value",(int)(Math.random()*100) + 1);
        map2.put("name","C#语言");
        map2.put("value",(int)(Math.random()*100) + 1);
        map3.put("name","python语言");
        map3.put("value",(int)(Math.random()*100) + 1);
        map4.put("name","sql语言");
        map4.put("value",(int)(Math.random()*100) + 1);
        map5.put("name","javascript语言");
        map5.put("value",(int)(Math.random()*100) + 1);
        map6.put("name","php语言");
        map6.put("value",(int)(Math.random()*100) + 1);
        list.add(map1);
        list.add(map2);
        list.add(map3);
        list.add(map4);
        list.add(map5);
        list.add(map6);
        return JMResult.result(list);
    }

    @GetMapping("/daping4")
    public JMResult daping4(){
        List<Map<String,Object>> list = new ArrayList<>();
        Map<String,Object> map1 = new HashMap<>();
        Map<String,Object> map2 = new HashMap<>();
        Map<String,Object> map3 = new HashMap<>();
        Map<String,Object> map4 = new HashMap<>();
        Map<String,Object> map5 = new HashMap<>();
        Map<String,Object> map6 = new HashMap<>();
        String[] namelist = {
                "吉林","北京","上海","重庆","西藏","内蒙古",
                "甘肃","河北","江苏","黑龙江","青海","新疆",
                "辽宁","河北","安徽","山东","山西","河南",
                "湖南","湖北","贵州","浙江","云南","福建",
        };
        map1.put("name",namelist[(int)(Math.random()*11)]);
        map1.put("value",(int)(Math.random()*100) + 1);
        map2.put("name",namelist[(int)(Math.random()*11)]);
        map2.put("value",(int)(Math.random()*100) + 1);
        map3.put("name",namelist[(int)(Math.random()*11)]);
        map3.put("value",(int)(Math.random()*100) + 1);
        map4.put("name",namelist[(int)(Math.random()*11)]);
        map4.put("value",(int)(Math.random()*100) + 1);
        map5.put("name",namelist[(int)(Math.random()*11)]);
        map5.put("value",(int)(Math.random()*100) + 1);
        map6.put("name",namelist[(int)(Math.random()*11)]);
        map6.put("value",(int)(Math.random()*100) + 1);
        list.add(map1);
        list.add(map2);
        list.add(map3);
        list.add(map4);
        list.add(map5);
        list.add(map6);
        return JMResult.result(list);
    }
}

